﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Surface;
using Microsoft.Surface.Core;

namespace Sublimation
{
    public class WorldPropertiesSurf : WorldProperties
    {
        protected ReadOnlyContactCollection contacts;
        public ReadOnlyContactCollection Contacts
        {
            get
            {
                return contacts;
            }
            set
            {
                contacts = value;
            }
        }

        //list of contacts that can by owned by an object
        protected List<int> owned;
        public List<int> Owned
        {
            get
            {
                return owned;
            }
        }

        public WorldPropertiesSurf(Game game)
            : base(game)
        {
            owned = new List<int>();
            factory = new FactorySurf();
            screen.Kill();
            screen = new EndScreenSurf(this);
        }

        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            
            
            foreach (Contact contact in contacts)
            {
                map.PhysicalObjects = new List<Rectangle>();
                if (!contact.IsFingerRecognized && !contact.IsTagRecognized)
                {
                   map.PhysicalObjects.Add(new Rectangle((int)contact.Bounds.Left, (int)contact.Bounds.Top, (int)contact.Bounds.Width, (int)contact.Bounds.Height));
                }
                if (Owned.Contains(contact.Id))
                {
                    continue;
                }

            }
            for (int i = 0; i < owned.Count;i++ )
            {
                if (!contacts.Contains(i))
                {
                    owned.Remove(i);
                }
            }
        }
    }
}